﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IFPRJ.EF.Model;
using IFPRJ.EF.DALayer;

namespace IFPRJ.EF.DALayer.Providers.MySql
{
    public class PostProvider : IPost
    {
        public static IFDBContext dbcontext = new IFDBContext();

        public PostProvider()
        {
        }

        IFDBContext GetCurrentDBContext()
        {
            if (dbcontext == null)
                return new IFDBContext();
            else
                return dbcontext;

        }


        public bool PostCreate(Post post)
        {
            IFDBContext db = GetCurrentDBContext();
            bool result = false;
            try
            {
                db.Posts.Add(post);
                db.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                throw e;

            }
            return result;
        }

        public bool PostUpdate(Post post)
        {
            return true;
        }

        public bool PostDelete(Post post)
        {
            return true;
        }

        public List<Post> PostLoadAll()
        {
            return new List<Post>();
        }

        public Post PostGetSingleByPostId(int postid)
        {
            return new Post();
        }

        public List<Post> PostGetListByCatoryId(int catoryid)
        {
            return new List<Post>();
        }
    }
}
